﻿using ET.DBCommon.DAL;
using ET.DBCommon.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ET.ScoreTeacherClient.Views
{
    /// <summary>
    /// WinTrainLate.xaml 的交互逻辑
    /// </summary>
    public partial class WinTrainLate : Window
    {
        private int QuestionID { get; set; }
        public List<ExamresultsTestQuestionTaskStepModel> StepModels { get; set; }
        public string[] StopsRunningTrain { get; set; }
        public WinTrainLate(string arg, List<ExamresultsTestQuestionTaskStepModel> stepModels = null)
        {
            InitializeComponent();
            string[] args = arg.Split('：');
            this.Title = args[0];
            this.QuestionID = int.Parse(args[1]);
            this.StopsRunningTrain = args[2].Split(',');
            this.StepModels = stepModels;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataGridHidden();
            if (this.Title.Contains("晚点扣分"))
            {
                this.dgTrainLate.Visibility = Visibility.Visible;
                this.dgTrainLate.ItemsSource = TrainLateDAL.GetTrainLateList(this.QuestionID);
            }
            if (this.Title.Contains("迫停扣分"))
            {
                this.dgTrainSuspend.Visibility = Visibility.Visible;
                this.dgTrainSuspend.ItemsSource = TrainSuspendDAL.GetTrainSuspendList(this.QuestionID);
            }
            if (this.Title.Contains("提交元素扣分"))
            {
                this.dgRecordtime.Visibility = Visibility.Visible;
                this.dgRecordtime.ItemsSource = RecordtimeDAL.GetRecordtimeList(this.QuestionID);
            }
            if (this.Title.Contains("操作得分"))
            {
                this.dgExamResults.Visibility = Visibility.Visible;
                this.dgExamResults.ItemsSource = ExamResultsLogDAL.GetExamResultsList(this.QuestionID);
            }
            if (this.Title.Contains("扣分步骤"))
            {
                this.dgSteps.Visibility = Visibility.Visible;
                //修改扣分步骤显示问题 modfiy by ljz 2023.8.9
                this.dgSteps.ItemsSource = this.StepModels;
            }
            if (this.Title.Contains("停运扣分"))
            {
                this.dgStopsRunning.Visibility = Visibility.Visible;
                this.dgStopsRunning.ItemsSource = ExamResultsLogDAL.GetLateTrain(this.QuestionID);

            }
            if (this.Title.Contains("客流扣分"))
            {
                this.Passenger.Visibility= Visibility.Visible;
                this.Passenger.ItemsSource = ExamResultsLogDAL.GetPassenger(this.QuestionID);
            }
        }

        private void DataGridHidden()
        {
            this.dgTrainSuspend.Visibility = Visibility.Collapsed;
            this.dgTrainLate.Visibility = Visibility.Collapsed;
            this.dgRecordtime.Visibility = Visibility.Collapsed;
            this.dgExamResults.Visibility = Visibility.Collapsed;
            this.dgSteps.Visibility = Visibility.Collapsed;
            this.dgStopsRunning.Visibility = Visibility.Collapsed;
            this.Passenger.Visibility = Visibility.Collapsed;
        }
    }
}
